<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>21.弹性元素排序实例</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    body {
      padding: 15px;
    }

    article {
      border: solid 5px silver;
      width: 400px;
      height: 500px;
      padding: 10px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;

    }

    article section {
      flex: 1 0 100px;
      background: blueviolet;
      background-clip: content-box;
      padding: 10px;
      text-align: center;
      display: flex;
      flex-direction: column;
      order: 1;
    }

    article section div {
      flex: 1;
      color: #fff;
      display: flex;
      justify-content: center;
      flex-direction: column;
    }

    article section span {
      padding: 10px;
      background: #333;
    }
  </style>
</head>

<body>
  <article>
    <section>
      <div>houdunren.com</div>
      <span onclick="up(this)">up</span>
    </section>
    <section>
      <div>后盾人.com</div>
      <span onclick="up(this)">up</span>
    </section>
    <section>
      <div>hdcms.com</div>
      <span onclick="up(this)">up</span>
    </section>
  </article>
  <script>
    function up (el) {
      let order = getOrder(el);
      el.parentElement.style.order = order * 1 - 1;
      console.log(getOrder(el.parentElement))
    }
    function getOrder (el) {
      return getComputedStyle(el, null).order;
    }
  </script>
</body>

</html>